import Page
from Page import Xting
from Base.Base import Base
from selenium.webdriver.common.by import By


class XtingLocalRadioPage(Base):
    """
    想听-本地电台页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 开关机按钮
        self.local_radio_power_btn = (By.XPATH, Xting.RESOURCE_ID.format("ib_power"))

        # FM按钮
        self.local_radio_FM_btn = (By.XPATH, Xting.RESOURCE_ID.format("tv_fm"))

        # AM按钮
        self.local_radio_AM_btn = (By.XPATH, Xting.RESOURCE_ID.format("tv_am"))

        # 搜台
        self.local_radio_search_btn = (By.XPATH, Page.TEXT.format("搜台"))

        # 收藏按钮
        self.local_radio_collect_btn = (By.XPATH, Xting.RESOURCE_ID.format("ivLike"))

        # 已添加的FM/AM列表, 默认取1
        self.local_radio_list_added_radio_btn = (By.XPATH, Xting.local_radio_list_added_radio_btn.format(1))

    def get_list_added_radio(self, index=1):
        """
        获取本地电台页面的指定索引的已添加节目

        :param index: 标签的索引, 取值范围:[1~6]
        :return: 元素对象
        """
        self.local_radio_list_added_radio_btn = (By.XPATH, Xting.local_radio_list_added_radio_btn.format(index))
        print(self.local_radio_list_added_radio_btn)
        return self.find_element_o(self.local_radio_list_added_radio_btn)


    def click_list_added_radio(self, index=1):
        """
        点击本地电台页面的指定索引的已添加节目

        :param index: 标签的索引, 取值范围: 1~6
        :return: None
        """
        self.local_radio_list_added_radio_btn = (By.XPATH, Xting.local_radio_list_added_radio_btn.format(index))

        self.click_element(self.local_radio_list_added_radio_btn)


if __name__ == '__main__':
    pass
